import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

// 解决重复点击同一个路由导致报错问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

const routes = [
  {
    path: '/login',
    component: () => import('@/views/login.vue')
  }, {
    path: '/productDetail',
    component: () => import('@/views/productDetail.vue'),
  },
  {
    path: "/personal",
    component: () => import("@/views/personal.vue")
  },
  {
    path: "/order",
    component: () => import("@/views/order.vue")
  }, {
    path: '/search',
    component: () => import('@/views/search.vue')
  },
  {
    path: "/citysite",
    component: () =>
      import("@/views/citysite.vue")
  },
  {
    path: "/home",
    component: () =>
      import("@/views/home.vue")
  },
  {
    path: '/shopList',
    component: () => import('@/views/shop/index.vue'),
    redirect: '/shopList/goods-detail',
    children: [
      { path: 'goods-detail', component: () => import('@/views/shop/Shop.vue') },
      { path: 'goods-comment', component: () => import('@/views/shop/comment.vue') },
    ]
  },
  { path: '/', redirect: '/home' },
  { path: '/index', component: () => import('@/views/index.vue') },
  { path: '/index_entry', component: () => import('@/views/index_entry.vue') }

]

const router = new VueRouter({
  routes
})

export default router